package com.hanlin.backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hanlin.backend.common.entity.HlUserInfo;
import com.hanlin.backend.mapper.HlUserInfoMapper;
import com.hanlin.backend.service.HlUserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户基础信息表 服务实现类
 * </p>
 *
 * @author hl.yuan
 * @since 2021-01-06
 */
@Service
@Slf4j
public class HlUserInfoServiceImpl extends ServiceImpl<HlUserInfoMapper, HlUserInfo> implements HlUserInfoService {

    @Override
    public HlUserInfo getUserInfoByUserId(Integer userId) {
        if (userId == null) {
            log.info("用户ID为空，直接返回null");
            return null;
        }
        QueryWrapper wrapper = new QueryWrapper();

        wrapper.eq("user_id", userId);

        HlUserInfo hlUserInfo = this.getBaseMapper().selectOne(wrapper);

        return hlUserInfo;
    }
}
